/*======================= COPYRIGHT NOTICE ==================================*]
[* Copyright (c) 2019-2020 Qualcomm Technologies, Inc.                       *]
[* All Rights Reserved.                                                      *]
[* Confidential and Proprietary - Qualcomm Technologies, Inc.                *]
[*===========================================================================*/
#ifndef __SIGMOID_FIXED_COEF_KALIMBA_H__
#define __SIGMOID_FIXED_COEF_KALIMBA_H__

#define SIGMOID_MAX_IDX (257)          /**< Number of rows in sigmoid LUT */
#define SIGMOID_LUT_SCALING_FACTOR (4) /**< Scaling factor is fixed for 4 for sigmoid */
#define SIGMOID_LOG_2_N_LUT (8)        /**<log_base_2(256) = 8, 256 data points in each LUT */

#define SIGMOID_LUT_SPC (0.00390625r)           /**<1/256 spacing between two points on LUT */
#define SIGMOID_SPC_BY_2 (SIGMOID_LUT_SPC >> 1) /**<Half of SPC */
#define SIGMOID_OFFSET (0.5r)                   /**<Offset to get actual sigmoid*/

#define SIGMOID_INDEX_MASK (0xFF)     /**<Mask to get bits 30 to 23 after shift by 23*/
#define SIGMOID_INDEX_SHIFT (23)      /**<Shift for index*/
#define SIGMOID_DELTA_MASK (0x7FFFFF) /**<Mask to get 23 least significant bits*/
#define SIGMOID_SIGN_SHIFT (31)       /**<Bit shifts required to get sign bit from 32 bit value */
/**
 * @brief Look up table for sigmoid function
 * @note
 *    - Range : [0, 16]
 *    - LUT0 is the original function -0.5, LUT1 is the gradient and LUT2 is the second derivative divided by 2
 *    - Precision : 10 decimal digits
 *    - No presumed scaling
 */

DMCONST sat fract sigmoid_lut[SIGMOID_MAX_IDX][3] = {
    {0.0000000000r, 0.2500000000r, -0.0000000000r}, {0.0156199159r, 0.2497560182r, -0.0039011678r},
    {0.0312093734r, 0.2490259749r, -0.0077719446r}, {0.0467381519r, 0.2478155452r, -0.0115824407r},
    {0.0621765009r, 0.2461340828r, -0.0153037561r}, {0.0774953654r, 0.2439944684r, -0.0189084406r},
    {0.0926665999r, 0.2414129013r, -0.0223709126r}, {0.1076631700r, 0.2384086419r, -0.0256678299r},
    {0.1224593311r, 0.2350037121r, -0.0287783975r}, {0.1370307943r, 0.2312225616r, -0.0316846115r},
    {0.1513548647r, 0.2270917050r, -0.0343714342r}, {0.1654105587r, 0.2226393470r, -0.0368268988r},
    {0.1791786994r, 0.2178949937r, -0.0390421418r}, {0.1926419833r, 0.2128890664r, -0.0410113721r},
    {0.2057850277r, 0.2076525223r, -0.0427317801r}, {0.2185943928r, 0.2022164916r, -0.0442033913r},
    {0.2310585785r, 0.1966119334r, -0.0454288740r}, {0.2431680085r, 0.1908693197r, -0.0464133122r},
    {0.2549149869r, 0.1850183494r, -0.0471639503r}, {0.2662936430r, 0.1790876957r, -0.0476899147r},
    {0.2772998610r, 0.1731047868r, -0.0480019334r}, {0.2879311955r, 0.1670956267r, -0.0481120436r},
    {0.2981867776r, 0.1610846454r, -0.0480333115r}, {0.3080672137r, 0.1550945919r, -0.0477795587r},
    {0.3175744764r, 0.1491464521r, -0.0473651062r}, {0.3267117939r, 0.1432594038r, -0.0468045366r},
    {0.3354835371r, 0.1374507966r, -0.0461124792r}, {0.3438951024r, 0.1317361584r, -0.0453034197r},
    {0.3519528019r, 0.1261292254r, -0.0443915343r}, {0.3596637505r, 0.1206419864r, -0.0433905493r},
    {0.3670357596r, 0.1152847512r, -0.0423136260r}, {0.3740772353r, 0.1100662220r, -0.0411732681r},
    {0.3807970779r, 0.1049935855r, -0.0399812507r}, {0.3872045935r, 0.1000726027r, -0.0387485716r},
    {0.3933094060r, 0.0953077110r, -0.0374854193r}, {0.3991213772r, 0.0907021263r, -0.0362011576r},
    {0.4046505350r, 0.0862579443r, -0.0349043235r}, {0.4099070062r, 0.0819762466r, -0.0336026377r},
    {0.4149009548r, 0.0778571977r, -0.0323030255r}, {0.4196425313r, 0.0739001459r, -0.0310116443r},
    {0.4241418201r, 0.0701037166r, -0.0297339181r}, {0.4284088006r, 0.0664658998r, -0.0284745763r},
    {0.4324533087r, 0.0629841355r, -0.0272376980r}, {0.4362850059r, 0.0596553939r, -0.0260267537r},
    {0.4399133497r, 0.0564762447r, -0.0248446539r}, {0.4433475747r, 0.0534429280r, -0.0236937925r},
    {0.4465966704r, 0.0505514140r, -0.0225760932r}, {0.4496693676r, 0.0477974601r, -0.0214930535r},
    {0.4525741269r, 0.0451766597r, -0.0204457873r}, {0.4553191299r, 0.0426844903r, -0.0194350649r},
    {0.4579122723r, 0.0403163512r, -0.0184613517r}, {0.4603611608r, 0.0380676016r, -0.0175248454r},
    {0.4626731128r, 0.0359335910r, -0.0166255063r}, {0.4648551536r, 0.0339096864r, -0.0157630923r},
    {0.4669140214r, 0.0319912964r, -0.0149371848r}, {0.4688561694r, 0.0301738922r, -0.0141472155r},
    {0.4706877694r, 0.0284530241r, -0.0133924903r}, {0.4724147175r, 0.0268243346r, -0.0126722106r},
    {0.4740426429r, 0.0252835727r, -0.0119854915r}, {0.4755769097r, 0.0238266028r, -0.0113313822r},
    {0.4770226302r, 0.0224494105r, -0.0107088769r}, {0.4783846671r, 0.0211481103r, -0.0101169315r},
    {0.4796676468r, 0.0199189489r, -0.0095544751r}, {0.4808759633r, 0.0187583081r, -0.0090204193r},
    {0.4820137899r, 0.0176627063r, -0.0085136681r}, {0.4830850866r, 0.0166287990r, -0.0080331247r},
    {0.4840936083r, 0.0156533783r, -0.0075777005r}, {0.4850429134r, 0.0147333723r, -0.0071463180r},
    {0.4859363730r, 0.0138658416r, -0.0067379167r}, {0.4867771785r, 0.0130479787r, -0.0063514584r},
    {0.4875683491r, 0.0122771049r, -0.0059859278r}, {0.4883127422r, 0.0115506658r, -0.0056403372r},
    {0.4890130572r, 0.0108662299r, -0.0053137280r}, {0.4896718473r, 0.0102214818r, -0.0050051720r},
    {0.4902915237r, 0.0096142218r, -0.0047137714r}, {0.4908743626r, 0.0090423604r, -0.0044386629r},
    {0.4914225144r, 0.0085039120r, -0.0041790139r}, {0.4919380085r, 0.0079969959r, -0.0039340262r},
    {0.4924227586r, 0.0075198268r, -0.0037029339r}, {0.4928785712r, 0.0070707141r, -0.0034850035r},
    {0.4933071490r, 0.0066480567r, -0.0032795337r}, {0.4937100979r, 0.0062503391r, -0.0030858554r},
    {0.4940889310r, 0.0058761281r, -0.0029033297r}, {0.4944450753r, 0.0055240677r, -0.0027313479r},
    {0.4947798741r, 0.0051928759r, -0.0025693304r}, {0.4950945941r, 0.0048813429r, -0.0024167262r},
    {0.4953904278r, 0.0045883241r, -0.0022730120r}, {0.4956684979r, 0.0043127402r, -0.0021376894r},
    {0.4959298624r, 0.0040535717r, -0.0020102873r}, {0.4961755164r, 0.0038098572r, -0.0018903576r},
    {0.4964063973r, 0.0035806885r, -0.0017774766r}, {0.4966233876r, 0.0033652107r, -0.0016712425r},
    {0.4968273169r, 0.0031626169r, -0.0015712744r}, {0.4970189673r, 0.0029721460r, -0.0014772131r},
    {0.4971990730r, 0.0027930816r, -0.0013887174r}, {0.4973683259r, 0.0026247483r, -0.0013054665r},
    {0.4975273767r, 0.0024665091r, -0.0012271558r}, {0.4976768373r, 0.0023177653r, -0.0011534980r},
    {0.4978172835r, 0.0021779523r, -0.0010842225r}, {0.4979492566r, 0.0020465381r, -0.0010190723r},
    {0.4980732654r, 0.0019230223r, -0.0009578061r}, {0.4981897888r, 0.0018069344r, -0.0009001964r},
    {0.4982992774r, 0.0016978299r, -0.0008460274r}, {0.4984021545r, 0.0015952922r, -0.0007950971r},
    {0.4984988179r, 0.0014989288r, -0.0007472141r}, {0.4985896414r, 0.0014083693r, -0.0007021986r},
    {0.4986749776r, 0.0013232669r, -0.0006598802r}, {0.4987551565r, 0.0012432938r, -0.0006200993r},
    {0.4988304898r, 0.0011681425r, -0.0005827053r}, {0.4989012689r, 0.0010975241r, -0.0005475562r},
    {0.4989677691r, 0.0010311655r, -0.0005145185r}, {0.4990302483r, 0.0009688116r, -0.0004834663r},
    {0.4990889486r, 0.0009102211r, -0.0004542815r}, {0.4991440992r, 0.0008551679r, -0.0004268521r},
    {0.4991959142r, 0.0008034394r, -0.0004010736r}, {0.4992445945r, 0.0007548351r, -0.0003768471r},
    {0.4992903294r, 0.0007091668r, -0.0003540800r}, {0.4993332978r, 0.0006662579r, -0.0003326847r},
    {0.4993736660r, 0.0006259419r, -0.0003125789r}, {0.4994115913r, 0.0005880627r, -0.0002936851r},
    {0.4994472214r, 0.0005524731r, -0.0002759313r}, {0.4994806950r, 0.0005190354r, -0.0002592481r},
    {0.4995121430r, 0.0004876191r, -0.0002435716r}, {0.4995416873r, 0.0004581027r, -0.0002288413r},
    {0.4995694431r, 0.0004303716r, -0.0002150005r}, {0.4995955187r, 0.0004043179r, -0.0002019955r},
    {0.4996200153r, 0.0003798399r, -0.0001897756r}, {0.4996430292r, 0.0003568432r, -0.0001782943r},
    {0.4996646498r, 0.0003352375r, -0.0001675063r}, {0.4996849615r, 0.0003149393r, -0.0001573707r},
    {0.4997040429r, 0.0002958695r, -0.0001478470r}, {0.4997219690r, 0.0002779537r, -0.0001388998r},
    {0.4997388097r, 0.0002611219r, -0.0001304927r}, {0.4997546305r, 0.0002453094r, -0.0001225946r},
    {0.4997694935r, 0.0002304534r, -0.0001151739r}, {0.4997834559r, 0.0002164971r, -0.0001082015r},
    {0.4997965731r, 0.0002033855r, -0.0001016515r}, {0.4998088959r, 0.0001910678r, -0.0000954974r},
    {0.4998204722r, 0.0001794957r, -0.0000897157r}, {0.4998313473r, 0.0001686243r, -0.0000842838r},
    {0.4998415639r, 0.0001584110r, -0.0000791806r}, {0.4998511616r, 0.0001488165r, -0.0000743861r},
    {0.4998601777r, 0.0001398027r, -0.0000698818r}, {0.4998686481r, 0.0001313346r, -0.0000656499r},
    {0.4998766053r, 0.0001233793r, -0.0000616745r}, {0.4998840806r, 0.0001159059r, -0.0000579394r},
    {0.4998911032r, 0.0001088851r, -0.0000544307r}, {0.4998977003r, 0.0001022895r, -0.0000511343r},
    {0.4999038978r, 0.0000960934r, -0.0000480372r}, {0.4999097195r, 0.0000902722r, -0.0000451282r},
    {0.4999151891r, 0.0000848039r, -0.0000423947r}, {0.4999203272r, 0.0000796667r, -0.0000398271r},
    {0.4999251538r, 0.0000748406r, -0.0000374145r}, {0.4999296879r, 0.0000703069r, -0.0000351486r},
    {0.4999339478r, 0.0000660480r, -0.0000330196r}, {0.4999379497r, 0.0000620466r, -0.0000310196r},
    {0.4999417085r, 0.0000582878r, -0.0000291406r}, {0.4999452401r, 0.0000547566r, -0.0000273753r},
    {0.4999485579r, 0.0000514397r, -0.0000257171r}, {0.4999516741r, 0.0000483235r, -0.0000241594r},
    {0.4999546022r, 0.0000453959r, -0.0000226959r}, {0.4999573524r, 0.0000426457r, -0.0000213212r},
    {0.4999599364r, 0.0000400622r, -0.0000200295r}, {0.4999623634r, 0.0000376352r, -0.0000188160r},
    {0.4999646437r, 0.0000353549r, -0.0000176760r}, {0.4999667858r, 0.0000332133r, -0.0000166055r},
    {0.4999687979r, 0.0000312012r, -0.0000155997r}, {0.4999706885r, 0.0000293106r, -0.0000146544r},
    {0.4999724645r, 0.0000275350r, -0.0000137668r}, {0.4999741325r, 0.0000258666r, -0.0000129328r},
    {0.4999756999r, 0.0000242996r, -0.0000121491r}, {0.4999771719r, 0.0000228276r, -0.0000114134r},
    {0.4999785549r, 0.0000214446r, -0.0000107219r}, {0.4999798541r, 0.0000201454r, -0.0000100723r},
    {0.4999810751r, 0.0000189249r, -0.0000094622r}, {0.4999822215r, 0.0000177780r, -0.0000088890r},
    {0.4999832986r, 0.0000167009r, -0.0000083502r}, {0.4999843105r, 0.0000156895r, -0.0000078445r},
    {0.4999852609r, 0.0000147386r, -0.0000073691r}, {0.4999861540r, 0.0000138460r, -0.0000069225r},
    {0.4999869927r, 0.0000130069r, -0.0000065034r}, {0.4999877810r, 0.0000122190r, -0.0000061095r},
    {0.4999885214r, 0.0000114786r, -0.0000057393r}, {0.4999892167r, 0.0000107833r, -0.0000053914r},
    {0.4999898700r, 0.0000101300r, -0.0000050650r}, {0.4999904837r, 0.0000095163r, -0.0000047581r},
    {0.4999910602r, 0.0000089398r, -0.0000044699r}, {0.4999916018r, 0.0000083982r, -0.0000041989r},
    {0.4999921108r, 0.0000078892r, -0.0000039446r}, {0.4999925885r, 0.0000074110r, -0.0000037057r},
    {0.4999930379r, 0.0000069621r, -0.0000034813r}, {0.4999934598r, 0.0000065402r, -0.0000032703r},
    {0.4999938556r, 0.0000061439r, -0.0000030720r}, {0.4999942281r, 0.0000057719r, -0.0000028857r},
    {0.4999945778r, 0.0000054222r, -0.0000027111r}, {0.4999949061r, 0.0000050939r, -0.0000025467r},
    {0.4999952149r, 0.0000047851r, -0.0000023926r}, {0.4999955050r, 0.0000044950r, -0.0000022477r},
    {0.4999957774r, 0.0000042226r, -0.0000021113r}, {0.4999960330r, 0.0000039670r, -0.0000019833r},
    {0.4999962733r, 0.0000037267r, -0.0000018631r}, {0.4999964992r, 0.0000035008r, -0.0000017504r},
    {0.4999967110r, 0.0000032890r, -0.0000016443r}, {0.4999969103r, 0.0000030897r, -0.0000015446r},
    {0.4999970975r, 0.0000029025r, -0.0000014510r}, {0.4999972736r, 0.0000027264r, -0.0000013635r},
    {0.4999974389r, 0.0000025611r, -0.0000012806r}, {0.4999975939r, 0.0000024061r, -0.0000012033r},
    {0.4999977397r, 0.0000022603r, -0.0000011302r}, {0.4999978766r, 0.0000021234r, -0.0000010617r},
    {0.4999980051r, 0.0000019949r, -0.0000009974r}, {0.4999981262r, 0.0000018738r, -0.0000009369r},
    {0.4999982398r, 0.0000017602r, -0.0000008801r}, {0.4999983464r, 0.0000016536r, -0.0000008270r},
    {0.4999984466r, 0.0000015534r, -0.0000007767r}, {0.4999985406r, 0.0000014594r, -0.0000007297r},
    {0.4999986291r, 0.0000013709r, -0.0000006855r}, {0.4999987120r, 0.0000012880r, -0.0000006440r},
    {0.4999987902r, 0.0000012098r, -0.0000006049r}, {0.4999988633r, 0.0000011367r, -0.0000005681r},
    {0.4999989322r, 0.0000010678r, -0.0000005336r}, {0.4999989970r, 0.0000010030r, -0.0000005015r},
    {0.4999990580r, 0.0000009420r, -0.0000004712r}, {0.4999991148r, 0.0000008852r, -0.0000004424r},
    {0.4999991683r, 0.0000008317r, -0.0000004158r}, {0.4999992186r, 0.0000007814r, -0.0000003907r},
    {0.4999992661r, 0.0000007339r, -0.0000003669r}, {0.4999993108r, 0.0000006892r, -0.0000003446r},
    {0.4999993523r, 0.0000006477r, -0.0000003236r}, {0.4999993918r, 0.0000006082r, -0.0000003041r},
    {0.4999994286r, 0.0000005714r, -0.0000002859r}, {0.4999994631r, 0.0000005369r, -0.0000002682r},
    {0.4999994957r, 0.0000005043r, -0.0000002524r}, {0.4999995264r, 0.0000004736r, -0.0000002370r},
    {0.4999995548r, 0.0000004452r, -0.0000002226r}, {0.4999995818r, 0.0000004182r, -0.0000002091r},
    {0.4999996070r, 0.0000003930r, -0.0000001965r}, {0.4999996312r, 0.0000003688r, -0.0000001844r},
    {0.4999996535r, 0.0000003465r, -0.0000001732r}, {0.4999996745r, 0.0000003255r, -0.0000001630r},
    {0.4999996941r, 0.0000003059r, -0.0000001527r}, {0.4999997127r, 0.0000002873r, -0.0000001439r},
    {0.4999997299r, 0.0000002701r, -0.0000001350r}, {0.4999997462r, 0.0000002538r, -0.0000001267r},
    {0.4999997616r, 0.0000002384r, -0.0000001192r}, {0.4999997760r, 0.0000002240r, -0.0000001118r},
    {0.4999997900r, 0.0000002100r, -0.0000001052r}, {0.4999998026r, 0.0000001974r, -0.0000000987r},
    {0.4999998147r, 0.0000001853r, -0.0000000927r}, {0.4999998258r, 0.0000001742r, -0.0000000871r},
    {0.4999998361r, 0.0000001639r, -0.0000000820r}, {0.4999998463r, 0.0000001537r, -0.0000000768r},
    {0.4999998556r, 0.0000001444r, -0.0000000722r}, {0.4999998640r, 0.0000001360r, -0.0000000680r},
    {0.4999998724r, 0.0000001276r, -0.0000000638r}, {0.4999998803r, 0.0000001197r, -0.0000000601r},
    {0.4999998873r, 0.0000001127r, -0.0000000563r},
};

#endif // __SIGMOID_FIXED_COEF_KALIMBA_H___
